<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div class="box1" onclick="change()" id="mydiv" > ffff</div>
<!--<img src="https://img.zaozuo.com/4131c2d2fc9773d35ca5dc1a4c7a9122" id="img1" alt="" />-->
<!--<button id="img1">点击</button>-->
<script>
        // var Img = document.getElementById('img1');
        //
        // var onOff = true;  //此处相当于设置了一个开关，通过设置布尔值，进而通过改变布尔值来完成if的判断！
        // Img.onclick = function(){
        //     if( onOff ){
        //         Img.src = 'https://img.zaozuo.com/8c0dba6ce83b70158333b387051c498e';
        //         onOff = false;
        //     } else{
        //         Img.src = 'https://img.zaozuo.com/4131c2d2fc9773d35ca5dc1a4c7a9122';
        //         onOff = true;
        //     }
        // };

            function change(n){
                var emediv=document.getElementById('mydiv'+n);
                var su='true'
                if(su="true"){
                    if(emediv.onclick.src=="box1"){
                        //此处写后台交互
                        emediv.src="https://img.zaozuo.com/8c0dba6ce83b70158333b387051c498e";
                    }else{
                        emediv.src='https://img.zaozuo.com/4131c2d2fc9773d35ca5dc1a4c7a9122';
                    }
                }
            }

</script>
</body>
</html>
